package com.android.boncen.commonFrame.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.boncen.commonFrame.MyApplication;
import com.android.boncen.commonFrame.R;
import com.android.boncen.commonFrame.bean.ConsultationBean;
import com.android.boncen.commonFrame.bean.DoctorBean;

import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述:咨询记录
 *
 * @date 2017/2/8
 */

public class ConAdapter extends BaseAdapter {

    private LayoutInflater inflater;

    public void setData(List<ConsultationBean> data,boolean isClear) {
        if (isClear)
        {
            this.data.clear();
        }
        this.data.addAll(data);
        this.notifyDataSetChanged();
    }

    public List<ConsultationBean> data = new ArrayList<>();


    public ConAdapter(Context context) {
        super();
        inflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public ConsultationBean getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHond hond = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.con_item, parent, false);
            hond = new ViewHond();
            hond.tvTitle =  (TextView) convertView.findViewById(R.id.tvTitle);
            hond.tvContent = (TextView) convertView.findViewById(R.id.tvContent);
            hond.tvTime = (TextView) convertView.findViewById(R.id.tvTime);

            convertView.setTag(hond);

        } else {
            hond = (ViewHond) convertView.getTag();
        }
        final ConsultationBean bean = getItem(position);
        hond.tvTitle.setText(bean.getTitle());
        hond.tvContent.setText(bean.getContent());
        hond.tvTime.setText(bean.getUpdatedAt());

        return convertView;
    }

    static class ViewHond {
        TextView tvTitle;
        TextView tvContent;
        TextView tvTime;

    }


}
